<template>
  <div style="width: 100%;" class="f-column-Wcenter">
    <div class="header" style="width: 98%;">
     <div style="width: 50%;margin: 20px 0;" class="f-row-Hcenter">
       <el-input style="width: 200px;" v-model="query1.company" placeholder="机构名称"></el-input>
       <el-dropdown style="margin-left: 30px;" @command="handleCommand1">
         <el-button type="primary">
           {{query1.command}}<i class="el-icon-arrow-down el-icon--right"></i>
         </el-button>
         <el-dropdown-menu slot="dropdown">
           <el-dropdown-item command="0">全部</el-dropdown-item>
           <el-dropdown-item command="1">草稿</el-dropdown-item>
           <el-dropdown-item command="2">审核中</el-dropdown-item>
           <el-dropdown-item command="3">审批通过</el-dropdown-item>
           <el-dropdown-item command="4">审批不通过</el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>
       <el-button style="margin-left: 30px;" type="primary" icon="el-icon-search" @click="getTable(1)">搜索</el-button>
     </div>
    </div>
    <div class="table-box">
      <el-table ref="multipleTable" :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange">>
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column fixed prop="company" label="机构名称">
          <template slot-scope="scope">
            <div style="width:200px; white-space:nowrap; text-overflow:ellipsis; overflow: hidden; ">
              {{scope.row.company}}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="userId" label="账号">
        </el-table-column>
        <el-table-column prop="busScope" label="经验范围资料">
        </el-table-column>
        <el-table-column prop="busScopeGroupId" label="经验范围资料">
        </el-table-column>
        <el-table-column prop="bankCredit" label="资信证明">
        </el-table-column>
        <el-table-column prop="bankCreditGroupId" label="资信证明">
        </el-table-column>
        <el-table-column prop="capitalFlowGroupId" label="资金流水">
        </el-table-column>
        <el-table-column prop="createTime" label="申购时间">
        </el-table-column>
        <el-table-column prop="createTime" label="资信证明">
        </el-table-column>
        <el-table-column prop="approvalDesc" label="审批描述">
        </el-table-column>
        <el-table-column prop="status" label="项目状态">
          <template slot-scope="scope">

            <div class="f-row-Wcenter" style="color:#ff8f0f;">
              {{scope.row.status == 0 ?'不可用':''}}
              {{scope.row.status == 1 ?'草稿':''}}
              {{scope.row.status == 2 ?'审核中':''}}
              {{scope.row.status == 3 ?'审批通过':''}}
              {{scope.row.status == 4 ?'审批不通过':''}}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200" class="f-row-Hcenter">
          <template slot-scope="scope">
            <div class="f-row-Hcenter">
              <el-button @click="toDetails(scope.row)" type="text" size="small">详情</el-button>

            </div>
          </template>

        </el-table-column>
      </el-table>
      <div style="width: 100%;margin-top: 20px;" class="f-row-Hcenter">
        <div >
          <span>【功能待补充】</span>
          <el-button @click="toggleSelection([...tableData])">全选</el-button>
          <el-button @click="toggleSelection()">取消选择</el-button>
          <el-button @click="topage('发送短信')">发送短信</el-button>
          <el-button @click="topage('发送邮件')">发送邮件</el-button>
          <el-button @click="topage('导出')">导出</el-button>
        </div>
        <el-pagination style="margin-left: 100px;" background layout="prev, pager, next" :page-size="query1.pageSize" :total="query1.total"
          @prev-click="onprevclick" @next-click="onnextclick" @current-change="onCurrentChange">
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
  import serveApi from "@/api/serveApi"
  export default {


    data() {
      return {
        userId:'',
        query1: {
          command:'全部',
          company: '', //string企业名称
          end: '', // string($date-time)
          id: '', //integer($int64)主键
          start: '', //string($date-time)
          status: '', //string状态0草稿，1初审中，2初审不通过，3初审通过，4复审中，5复审不通过，6复审通过
          userId: '', //integer($int64)用户

          pageNum: 1, //integer($int32)页码
          pageSize: 6, //integer($int32)每页大小
          currentPage: 0, //当前页数
          totalPage: 1, //总页数
          total: 0, //总条数条数
          toastTitle: false, //显示加载
        },
        tableData: [],
        multipleSelection: []
      }
    },
    mounted() {
      this.getTable(1);
    },
    methods: {
      toDetails(row) {
        // this.$route.push({path:'/projects_details',params:row})
        this.$router.push({
          name: "underwritersDetails",
          query: row
        })
      },
      getTable(pageNum) {
        let that = this;
        if (pageNum > 0) {
          that.query1.pageNum = pageNum;
        }
        if (that.userId) {
          that.$message.error('userId为空')
          return;
        }

        serveApi.applyCon_selectByPage(this.query1).then(res => {
          if (res.status === "0000") {
            if (res.data) {
              //分页请求
              that.tableData = res.data;
              that.query1.totalPage = res.pages;
              that.query1.total = res.total;
              if (that.query1.currentPage >= that.query1.totalPage) {
                that.query1.toastTitle = true;
              } else {
                that.query1.toastTitle = false;
                that.query1.currentPage = that.query1.pageNum;
                that.query1.pageNum = that.query1.pageNum + 1;
              }
            }
          } else {
            that.$message.error(res.message);
          }
        });

      },
      onprevclick() {
        this.query1.currentPage = this.query1.currentPage - 1;
        this.query1.pageNum = this.query1.currentPage;
        this.getTable();
      },
      onnextclick() {
        this.getTable();
      },
      onCurrentChange(e) {
        this.getTable(e);
      },
      toggleSelection(rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      topage(e){
          console.log(e)
      },
      handleCommand1(command) {
        this.query1.status = command;
        if (this.query1.status == 0) {
          this.query1.command = '全部';
          delete this.query1.status;
        }
        if (this.query1.status == 1) {
          this.query1.command = '草稿';
        }
        if (this.query1.status == 2) {
          this.query1.command = '审核中';
        }
        if (this.query1.status == 3) {
          this.query1.command = '审批通过';
        }
        if (this.query1.status == 4) {
          this.query1.command = '审批不通过';
        }

      },

    }
  }
</script>

<style scoped lang="scss">
  .header {
    margin-top: 30px;
  }

  .table-box {
    width: 98%;
  }
</style>
